import { pinyin } from 'pinyin-pro'

export const pinyinFun = (text: any = '') => {
  return pinyin(text) || ''
}

export const FirstPy = (text: any) => {
  return pinyinFun(text)?.charAt(0) || ''
}

export const backgroundColor = (FirstPy: any) => {
  let bg = 'linear-gradient(133deg, #7294F0 0%, #6F92F0 6%, #386CF6 100%)'
  if (['g', 'h', 'o', 'w'].includes(FirstPy)) {
    bg = 'linear-gradient(135deg, #6F86F8 0%, #4661ED 100%)'
  }
  if (['b', 'i', 'p', 'u'].includes(FirstPy)) {
    bg = 'linear-gradient(133deg, #B38DF2 0%, #9160E3 100%)'
  }
  if (['c', 'j', 'q', 'x'].includes(FirstPy)) {
    bg = 'linear-gradient(133deg, #F4B278 0%, #F1903B 100%)'
  }
  if (['d', 'k', 'r', 'y'].includes(FirstPy)) {
    bg = 'linear-gradient(133deg, #8AE8B6 0%, #62C992 100%)'
  }
  if (['e', 'l', 's', 'z'].includes(FirstPy)) {
    bg = 'linear-gradient(133deg, #7ED9F2 0%, #58C2DF 100%)'
  }
  if (['f', 'm', 't'].includes(FirstPy)) {
    bg = 'linear-gradient(133deg, #E86875 0%, #DE4958 100%)'
  }
  if (['a', 'n', 'v'].includes(FirstPy)) {
    bg = 'linear-gradient(133deg, #7294F0 0%, #6F92F0 6%, #386CF6 100%)'
  }
  return bg
}

export const getBackgroundColor = (text: any) => {
  const FirstPyText = FirstPy(text)
  return backgroundColor(FirstPyText)
}
